<template>
  <div>
    <div class="product_con">
     
     <el-table :data="dataList" border style="width: 100%">
      <el-table-column prop="id" label="编号"> </el-table-column>
     <el-table-column prop="name" label="类型名称"> </el-table-column>
     <el-table-column prop="attribute_count" label="属性数量"> </el-table-column>
     <el-table-column prop="param_count" label="参数数量"> </el-table-column>
        <el-table-column  label="操作" > 
           <div class="click">
            <el-button class="click1" @click="editFun(scope.row.id)"> 编辑</el-button> 
             <el-button type="danger" class="click2" @click="delFun(scope.row.id)">删除</el-button>
           </div>
   </el-table-column>
    </el-table>

     <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="listQuery.pageNum"
      :page-sizes="[3, 5, 3,6]"
      :page-size="listQuery.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>

   </div>
  </div>
</template>

<script>
import { fetchDatelist } from "@/api/product";
export default {
       name: "productCate",
  data: function () {
    return {
      dataList: [],
       value: true,
        listQuery:{
        pageSize:10,//一页10条数据
        pageNum:1,//当前页
      },
      total:0
    };
  },
  methods: {
    //获取数据
    async getCateList() {
      const res = await fetchDatelist(this.listQuery);
      console.log(res);
      this.dataList = res.data;
         //3..获取数据的总量
      this.total=res.total
    },
        //修改
    editFun(id) {
      console.log("修改触发了", id);
    },
    //删除
    delFun(id) {
      console.log("删除触发了", id);
    },
      // 修改每页显示的条数
    handleSizeChange(val) {
      console.log("修改每页显示的条数 触发了", val);
      this.listQuery.pageSize = val;
      this.listQuery.pageNum = 1;
      //重新获取数据
    this.getCateList();
    },
    //6.修改当前页的页码
    handleCurrentChange(val) {
      console.log("修改当前页的页码 触发了", val);
      this.listQuery.pageNum = val;
       this.getCateList();
    },
     
  },
  mounted() {
    this.getCateList();
  },
}

</script>

<style>

</style>